package Test;

/**
 * @author feng
 * @Date 2021/12/24 10:44
 * 编写一个函数来查找字符串数组中的最长公共前缀。
 * 如果不存在公共前缀，返回空字符串 ""
 * 输入：strs = ["flower","flow","flight"]
 * 输出："fl"
 */
public class TestAcm16 {
    public static void main(String[] args) {
        String[] strs = {"flower", "flow", "flight"};
        String s = longestCommonPrefix(strs);
        System.out.println(s);
        System.out.println(strs.length);

    }

    public static String longestCommonPrefix(String[] strs) {
        String s = "";
        for (int i = 0; i < strs.length; i++) {
            s += strs[i];
        }
        return s;
    }
}
